package com.ct.shops.repository.admin;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ct.repository.commons.BaseServiceImpl;
import com.ct.shops.mapper.ShopsMapper;
import com.ct.shops.orm.Shops;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AdminShopsRepository extends BaseServiceImpl<ShopsMapper, Shops> implements IAdminShopsRepository {


    @Override
    public boolean updateOperatingStatus(Long id, Integer operatingStatus) {
        return this.lambdaUpdate()
                .set(Shops::getIsOperating,operatingStatus)
                .eq(Shops::getId,id)
                .update();
    }


    @Override
    public List<Shops> findShopsList() {
        LambdaQueryWrapper<Shops> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Shops::getStatus, 1);
        lambdaQueryWrapper.eq(Shops::getDeleteTag, 0);
        lambdaQueryWrapper.orderByDesc(Shops::getCreateTime);
        return this.list(lambdaQueryWrapper);
    }
}
